package com.niiwoo.civet.trade.service.dubbo.newRefund;

import com.alibaba.dubbo.config.annotation.Service;
import com.niiwoo.civet.trade.dao.entity.RefundOrderDetailBiz;
import com.niiwoo.civet.trade.dao.mapper.RefundOrderDetailBizMapperExt;
import com.niiwoo.civet.trade.dto.response.newRefund.RefundOrderDetailBizResponseDTO;
import com.niiwoo.civet.trade.service.newRefund.RefundOrderDetailBizDubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * 还款/垫付订单明细
 * 
 */
@Service(version = "1.0.0")
public class RefundOrderDetailBizDubboServiceImpl implements RefundOrderDetailBizDubboService {

    @Autowired
    private RefundOrderDetailBizMapperExt refundOrderDetailBizMapperExt;
    @Override
    public List<RefundOrderDetailBizResponseDTO> getDetailBizByRequest(String requestNo) {
        List<RefundOrderDetailBizResponseDTO> refundOrderDetailBizResponseDTOList = new ArrayList<>();
        List<RefundOrderDetailBiz> refundOrderDetailBizList = refundOrderDetailBizMapperExt.queryRefundOrderDetailBizByDetailRequestNo(requestNo);
        if(refundOrderDetailBizList.size() != 0){
            refundOrderDetailBizList.forEach(vo ->{
                RefundOrderDetailBizResponseDTO dto = new RefundOrderDetailBizResponseDTO();
                BeanUtils.copyProperties(vo,dto);
                refundOrderDetailBizResponseDTOList.add(dto);
            });
            return refundOrderDetailBizResponseDTOList;
        }
        return null;
    }

    @Override
    public RefundOrderDetailBizResponseDTO getDetailBizByRequestType(String requestNo, String bizType) {
        List<RefundOrderDetailBiz> refundOrderDetailBizList = refundOrderDetailBizMapperExt.queryRefundOrderDetailBizByDetailRequestNOType(requestNo,bizType);
        if(refundOrderDetailBizList.size() == 1){
            RefundOrderDetailBizResponseDTO dto = new RefundOrderDetailBizResponseDTO();
            RefundOrderDetailBiz vo = refundOrderDetailBizList.get(0);
            BeanUtils.copyProperties(vo,dto);
            return dto;
        }
        return null;
    }
}
